package com.maschinenstuermer.profiler.model.impl;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlType;

@XmlType
public class ProfiledMethod {
	@XmlAttribute(required=true)
	@XmlID
	private String name;

	@XmlElement
	private Metrics metrics = new Metrics();
	
	public ProfiledMethod() {
	}

	public ProfiledMethod(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public Metrics getMetrics() {
		return metrics;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((metrics == null) ? 0 : metrics.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ProfiledMethod other = (ProfiledMethod) obj;
		if (metrics == null) {
			if (other.metrics != null)
				return false;
		} else if (!metrics.equals(other.metrics))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
}
